package com.unbox.rabbit.producer;

import com.unbox.common.util.UnBoxUtils;
import com.unbox.common.util.UnboxLog;
import com.unbox.rabbit.comfig.RabbitConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class LogProducer {

    // 国际化日志输出
    UnboxLog unboxLog = new UnBoxUtils.LocaleMessageLog(LogProducer.class);

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送日志信息
     * @param massage
     */
    public void sendLogInfo(String massage){
        unboxLog.info("rabbit.producer.log.message", massage);
        rabbitTemplate.convertAndSend(RabbitConfig.LOG_EXCHANGE, "", massage);
    }
}
